package com.niuke;

import java.util.Scanner;
import java.util.Stack;

/**
 * 28. 找最小数
 * 类似 21. 最大值
 * https://zhuanlan.zhihu.com/p/533405389
 */
public class NiukeMoni28nan {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        char[] input = scanner.nextLine().toCharArray();
        int shanChu = Integer.parseInt(scanner.nextLine());

        // -----------------------------------------------------
        Stack<Character> stack = new Stack<>();

        int delete = 0;
        for (int i = 0; i < input.length; i++) {
            char curr = input[i];
            if (stack.size() > 0) {
                char top = stack.peek();
                while (stack.size() > 0 && delete < shanChu && curr < top) {
                    stack.pop();
                    delete++;
                    if (stack.size() > 0) {
                        top = stack.peek();
                    }
                }
            }
            stack.push(curr);
        }

        StringBuilder resultStr = new StringBuilder();
        boolean startAdd = false;
        for (int i = 0; i < stack.size() - shanChu + delete; i++) {
            if (startAdd || stack.get(i) != '0') {
                resultStr.append(stack.get(i));
                startAdd = true;
            }
        }

        System.out.println("".equals(resultStr.toString()) ? "0" : resultStr.toString());

    }

}
